package com.gylang.sso.config;

import com.gylang.common.jwt.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.security.PrivateKey;
import java.security.PublicKey;

/**
 * @author gylang,
 * @data 2019/12/7 12:12,
 * @DESC
 */
@Component
@Data
@ConfigurationProperties("rsa.key")
public class RsaKeyProperties {
    private String pubKeyFile;
    private String priKeyFile;

    @PostConstruct
    public void createRsaKey() throws Exception {
        publicKey = RsaUtils.getPublicKey(pubKeyFile);
        privateKey = RsaUtils.getPrivateKey(priKeyFile);
    }


    private PublicKey publicKey;
    private PrivateKey privateKey;
}
